<template>
  <!-- 前台导航 2018/2/14 18:23 zhangQ -->
  <Menu theme="light" mode="horizontal" style="z-index: 300;width:960px;margin:0 auto;"
        :active-name="activeMenu"
        @on-select="menuItemSelect">
    <div style="width: 960px; margin:0 auto;">
      <router-link :to="{path: '/'}" class="layout-logo">
        <img style="width:130px;height:37px;" src="../../../static/img/logo_bg.png" alt="">
      </router-link>
      <div class="layout-nav">
        <MenuItem name="frontIndex">
          首页
          <span class="line"></span>
        </MenuItem>
        <MenuItem name="productService">
          产品与服务
          <span class="line"></span>
        </MenuItem>
        <MenuItem name="abouts">
          关于我们
          <span class="line"></span>
        </MenuItem>
      </div>
    </div>

    <template v-if="!currentUser.userId">
      <MenuItem name="login_board" style="float: right">
        操作台
        <span class="line"></span>
      </MenuItem>
      <MenuItem name="reg" style="float: right">
        免费注册
        <span class="line"></span>
      </MenuItem>
      <MenuItem name="login" style="float: right">
        登录
        <span class="line"></span>
      </MenuItem>
    </template>
    <template v-else>

      <MenuItem name="board" style="float: right" v-if="currentUser.status == 1">
        操作中心
        <span class="line"></span>
      </MenuItem>

      <Dropdown class="nav-item" style="float: right;" placement="bottom-end" id="indexDropDown">
        <a href="javascript:void(0)" class="loginMenu">
          <span class="line"></span>
          <span slot="button">
            <Avatar :src="currentUser.headIco" size="small"/>
            <Icon type="ios-arrow-down" color="#fff" size="10"></Icon>
          </span>
        </a>
        <DropdownMenu slot="list" style="width: 120px;">
          <!--<DropdownItem v-if="currentUser.status == 1">-->
          <!--<a href="javascript:void(0)" @click="gotoDashboard" style="color:#fff;">-->
          <!--<i class="dashboardIcon"></i>-->
          <!--操作中心-->
          <!--</a>-->
          <!--</DropdownItem>-->
          <DropdownItem>
            <a href="javascript:void(0)" @click.prevent="logout" style="color:#fff;">
              <i class="logoutIcon"></i>
              退出登录
            </a>
          </DropdownItem>
        </DropdownMenu>
      </Dropdown>
    </template>
  </Menu>
</template>
<script>
  import {mapGetters} from 'vuex'

  export default {
    name: 'indexMenu',
    data () {
      let datas = {}
      return datas
    },
    created () {
    },
    methods: {
      logout () {
        this.$store.dispatch('logout').then(() => {
          this.$router.push({path: '/'})
        }).catch(err => {
          this.$message.error(err)
        })
      },
      /**
       * TODO(点击菜单触发)
       * @param
       * @auther zhangQ
       * @date 2018/2/15 13:16
       **/
      menuItemSelect (menuItemName) {
        this.$router.push({name: menuItemName})
      }
    },
    computed: {
      ...mapGetters(['currentUser', 'activeMenu'])
    }
  }
</script>
<style scoped>
  .layout {
    border: 1px solid #d7dde4;
    background: #fff;
  }

  .layout-logo {
    width: 200px;
    height: 40px;
    /* background: url("../../../static/img/logo_bg.png") no-repeat;*/
    border-radius: 3px;
    float: left;
    position: relative;
    top: 12px;
    left: 0;
  }

  .layout-nav {
    width: 600px;
    margin: 0 auto;
    color: #fff !important;
  }

  .layout-assistant {
    width: 300px;
    margin: 0 auto;
    height: inherit;
  }

  .layout-breadcrumb {
    padding: 10px 15px 0;
  }

  .layout-content {
    min-height: 200px;
    margin: 15px;
    overflow: hidden;
    background: #fff;
    border-radius: 4px;
  }

  .layout-content-main {
    padding: 10px;
  }

  .layout-copy {
    text-align: center;
    padding: 10px 0 20px;
    color: #9ea7b4;
  }

  #footer {
    width: 100%;
    margin: 0 auto;
    height: 460px;
    background: #13293b;
    position: relative;
  }

  .footers {
    width: 960px;
    margin: 0 auto;
    /*height: 150px;*/

    margin-top: 120px;
    /*border: 1px solid gray;*/

    display: flex;
    justify-content: space-between;
  }

  .footers > div {
    /*float: left;*/

    font-size: 14px;
  }

  .footers > div > p {
    font-size: 18px;
    color: #fdfdfd;
    border-left: 1px solid #1b364d;
    padding-left: 15px;
  }

  .footers > .foo4 > p {
    font-size: 14px;
    color: #cacaca;
    margin-top: 3px;
  }

  .footers > .foo4 > img {
    display: inline-block;
    width: 96px;
    height: 88px;
    border-left: 1px solid #1b364d;
    padding-left: 15px;
    padding-top: 8px;
  }

  .footers > .foo4 > p:first-of-type {
    font-size: 18px;
    color: #fdfdfd;
  }

  .footers > div > p > a {
    text-decoration: none;
    font-size: 14px;
    color: #cacaca;
  }

  .footers > div > p > span {
    text-decoration: none;
    font-size: 14px;
    color: #cacaca;
  }

  .mess {
    width: 70%;
    margin: 0 auto;
    margin-top: 60px;
    text-align: center;
  }

  #mianDeng {
    width: 960px;
    height: 160px;
    position: absolute;
    left: 50%;
    top: -50px;
    margin-left: -480px;
    background: #feca2e;
    border-bottom-left-radius: 25px;
    border-top-right-radius: 25px;
    z-index: 100;
    text-align: center;
  }

  #mianDeng > p:first-of-type {
    margin-top: 30px;
    font-size: 22px;
    color: #1b1e21;
  }

  #mianDeng > p:last-of-type {
    width: 120px;
    height: 40px;
    margin: 0 auto;
    margin-top: 30px;
    background-color: #1b1e21;
    line-height: 40px;
  }

  #mianDeng a {
    text-decoration: none;
    color: #feca2e;
    font-size: 16px;
  }

  .loginMenu {
    padding: 0 5px;
    display: inline-block;
    height: 60px;
    position: relative;
  }

  .loginMenu:hover {
    background-color: #0A1E2E;
    height: 60px;
    transition: all 300ms ease-in;
  }

  .loginMenu .line {
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #FECA2E;
    height: 2px;
    display: none;
  }

  .loginMenu:hover .line {
    display: block;
  }

  .sendMessage {
    float: right;
    position: relative;
    height: 60px;;
    width: 30px;
  }

  .sendMessage a {
    display: block;
    position: relative;
  }

  .messsageNum {
    position: absolute;
    height: 10px;
    width: 30px;
    text-align: center;
    color: #fff;
    font-size: 9px;
    top: 11px;
    right: 2px;
  }

  .ivu-menu-light.ivu-menu-horizontal .ivu-menu-item-active, .ivu-menu-light.ivu-menu-horizontal .ivu-menu-item:hover {
    border: none;
    color: #FED557;
  }

  .ivu-menu-light.ivu-menu-horizontal .ivu-menu-item {
    font-size: 16px;
    color: #fff;
    position: relative;
  }

  .ivu-menu-item .line {
    display: none;
    position: absolute;
    bottom: 0;
    width: 14px;
    height: 4px;
    background-color: #FED557;
    left: 50%;
    margin-left: -7px;
  }

  .ivu-menu-light.ivu-menu-horizontal .ivu-menu-item-active {
    color: #FED557;
  }

  .ivu-menu-item-selected .line {
    display: block;
  }

  .ivu-menu-horizontal.ivu-menu-light:after {
    background-color: #13293B;
  }

  .ivu-menu-light.ivu-menu-horizontal .ivu-menu-item, .ivu-menu-light.ivu-menu-horizontal .ivu-menu-submenu {
    border: none;
  }

  .ivu-layout-header {
    background-color: transparent;
  }

  .ivu-menu-light {
    background-color: transparent;
  }

  .ivu-menu-horizontal.ivu-menu-light:after {
    background-color: transparent;
  }

  .ivu-layout-header:hover {
    background-color: #13293B;
    transition: all 300ms ease-in;
  }
</style>
<style>
  #indexDropDown .ivu-select-dropdown {
    margin-top: -2px;
    background-color: #0A1E2E;
  }

  #indexDropDown .ivu-dropdown-item a {
    color: #fff;
  }

  #indexDropDown .ivu-dropdown-item:hover {
    background-color: transparent;
  }

  #indexDropDown .ivu-dropdown-item:hover a {
    color: #FED557 !important;
  }

  #indexDropDown .dashboardIcon {
    display: block;
    margin-right: 3px;
    float: left;
    background: url("../../../static/img/icon_operating.png") no-repeat;
    padding: 9px;

  }

  #indexDropDown .logoutIcon {
    margin-right: 3px;
    display: block;
    float: left;
    background: url("../../../static/img/icon_exit.png") no-repeat;
    padding: 9px;
  }
</style>
